from django.db import models
from utils.basemodel import BasaModel

# Create your models here.
class UserModel(BasaModel):
    username = models.CharField(max_length=15,verbose_name="用户名",blank=True,unique=True,null=True)
    password = models.CharField(max_length=20,verbose_name="密码",blank=True,unique=True,null=True)
    phone = models.CharField(max_length=15,verbose_name="手机号",blank=True,unique=True,null=True)
    email = models.EmailField(verbose_name="邮箱",blank=True,unique=True,null=True)
    cridet = models.IntegerField(default=1,verbose_name="用户积分")
    headimg = models.ImageField(upload_to="uploads", blank=True,null=True,max_length=100,verbose_name="用户头像")
    class Meta:
        db_table = "user"
        verbose_name_plural = "用户表"
class AddressModel(models.Model):
    name = models.CharField(max_length=10,verbose_name='用户名', blank=True,null=True)
    phone = models.CharField(max_length=11,verbose_name='电话', blank=True,null=True)
    area = models.CharField(max_length=50,verbose_name='所在地区', blank=True,null=True)
    aname = models.CharField(max_length=200,verbose_name="地址")
    address = models.CharField(max_length=200,verbose_name="详细地址", blank=True,null=True)
    user = models.ForeignKey(UserModel, on_delete=models.CASCADE,null=True,blank=True,verbose_name="用户")
    class Meta:
        db_table = "address"
        verbose_name_plural = "收货地址"
    def __str__(self):
        return self.aname



